home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 118 / cd-rom 118.iso / aplic / open / openofficeorg2.cab / table_columns.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2004-09-20  |  12.9 KB  |  271 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.    $RCSfile: table_columns.xsl,v $
  5.  
  6.    $Revision: 1.4 $
  7.  
  8.    last change: $Author: rt $ $Date: 2004/09/20 12:21:55 $
  9.  
  10.    The Contents of this file are made available subject to the terms of
  11.    either of the following licenses
  12.  
  13.           - GNU Lesser General Public License Version 2.1
  14.           - Sun Industry Standards Source License Version 1.1
  15.  
  16.    Sun Microsystems Inc., October, 2000
  17.  
  18.    GNU Lesser General Public License Version 2.1
  19.    =============================================
  20.    Copyright 2000 by Sun Microsystems, Inc.
  21.    901 San Antonio Road, Palo Alto, CA 94303, USA
  22.  
  23.    This library is free software; you can redistribute it and/or
  24.    modify it under the terms of the GNU Lesser General Public
  25.    License version 2.1, as published by the Free Software Foundation.
  26.  
  27.    This library is distributed in the hope that it will be useful,
  28.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  29.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  30.    Lesser General Public License for more details.
  31.  
  32.    You should have received a copy of the GNU Lesser General Public
  33.    License along with this library; if not, write to the Free Software
  34.    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  35.    MA  02111-1307  USA
  36.  
  37.  
  38.    Sun Industry Standards Source License Version 1.1
  39.    =================================================
  40.    The contents of this file are subject to the Sun Industry Standards
  41.    Source License Version 1.1 (the "License"); You may not use this file
  42.    except in compliance with the License. You may obtain a copy of the
  43.    License at http://www.openoffice.org/license.html.
  44.  
  45.    Software provided under this License is provided on an "AS IS" basis,
  46.    WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
  47.    WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
  48.    MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
  49.    See the License for the specific provisions governing your rights and
  50.    obligations concerning the Software.
  51.  
  52.    The Initial Developer of the Original Code is: Sun Microsystems, Inc.
  53.  
  54.    Copyright ┬⌐ 2002 by Sun Microsystems, Inc.
  55.  
  56.    All Rights Reserved.
  57.  
  58.    Contributor(s): _______________________________________
  59.  
  60. -->
  61. <!--
  62.     For further documentation and updates visit http://xml.openoffice.org/sx2ml
  63. -->
  64. <xsl:stylesheet version="1.0"
  65.     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  66.     xmlns:office="http://openoffice.org/2000/office"
  67.     xmlns:style="http://openoffice.org/2000/style"
  68.     xmlns:text="http://openoffice.org/2000/text"
  69.     xmlns:table="http://openoffice.org/2000/table"
  70.     xmlns:draw="http://openoffice.org/2000/drawing"
  71.     xmlns:fo="http://www.w3.org/1999/XSL/Format"
  72.     xmlns:xlink="http://www.w3.org/1999/xlink"
  73.     xmlns:number="http://openoffice.org/2000/datastyle"
  74.     xmlns:svg="http://www.w3.org/2000/svg"
  75.     xmlns:chart="http://openoffice.org/2000/chart"
  76.     xmlns:dr3d="http://openoffice.org/2000/dr3d"
  77.     xmlns:math="http://www.w3.org/1998/Math/MathML"
  78.     xmlns:form="http://openoffice.org/2000/form"
  79.     xmlns:script="http://openoffice.org/2000/script"
  80.     xmlns:dc="http://purl.org/dc/elements/1.1/"
  81.     xmlns:meta="http://openoffice.org/2000/meta"
  82.     xmlns:config="http://openoffice.org/2001/config"
  83.     xmlns:help="http://openoffice.org/2000/help"
  84.     xmlns:xt="http://www.jclark.com/xt"
  85.     xmlns:common="http://exslt.org/common"
  86.     xmlns:xalan="http://xml.apache.org/xalan"
  87.     exclude-result-prefixes="office style text table draw fo xlink number svg chart dr3d math form script dc meta config help xt common xalan">
  88.  
  89.     <xsl:param name="tableColumnElement"            select="'col'" />
  90.  
  91.     <!-- ******************************************** -->
  92.     <!-- *** Create table columns style variable  *** -->
  93.     <!-- ******************************************** -->
  94.  
  95.     <!-- current node is a table:table or table:sub-table -->
  96.     <xsl:template name="create-column-style-variable">
  97.         <xsl:param name="globalData" />
  98.         <xsl:param name="allVisibleTableRows" />
  99.  
  100.         <!-- all columns of the table -->
  101.         <xsl:variable name="allTableColumns" select="table:table-column |
  102.                                                      table:table-column-group/descendant::table:table-column |
  103.                                                      table:table-header-columns/descendant::table:table-column" />
  104.         <!-- allTableColumns: Containing all columns of the table, hidden and viewed.
  105.             - if a column is hidden, if table:visibility has the value 'collapse' or 'filter', otherwise the value is 'visible'
  106.             - if a column is being repeated, each repeated column is explicitly written as entry in this variable.
  107.               Later (during template "write-cell") the style of the column will be mixed with the cell-style by using
  108.               the position() of the column entry and comparing it with the iterating cell number. -->
  109.         <xsl:variable name="allTableColumns-RTF">
  110.             <xsl:for-each select="$allTableColumns">
  111.                 <xsl:call-template name="adding-column-styles-entries">
  112.                     <xsl:with-param name="globalData"       select="$globalData" />
  113.                     <xsl:with-param name="allTableColumns"  select="$allTableColumns" />
  114.                 </xsl:call-template>
  115.             </xsl:for-each>
  116.         </xsl:variable>
  117.  
  118.         <xsl:choose>
  119.             <xsl:when test="function-available('xt:node-set')">
  120.                 <xsl:call-template name="create-table-children">
  121.                     <xsl:with-param name="globalData"           select="$globalData" />
  122.                     <xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
  123.                     <xsl:with-param name="allTableColumns"      select="xt:node-set($allTableColumns-RTF)" />
  124.                 </xsl:call-template>
  125.             </xsl:when>
  126.             <xsl:when test="function-available('xalan:nodeset')">
  127.                 <xsl:call-template name="create-table-children">
  128.                     <xsl:with-param name="globalData"           select="$globalData" />
  129.                     <xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
  130.                     <xsl:with-param name="allTableColumns"      select="xalan:nodeset($allTableColumns-RTF)" />
  131.                 </xsl:call-template>
  132.             </xsl:when>
  133.             <xsl:when test="function-available('common:node-set')">
  134.                 <xsl:call-template name="create-table-children">
  135.                     <xsl:with-param name="globalData"           select="$globalData" />
  136.                     <xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
  137.                     <xsl:with-param name="allTableColumns"      select="common:node-set($allTableColumns-RTF)" />
  138.                 </xsl:call-template>
  139.             </xsl:when>
  140.         </xsl:choose>
  141.     </xsl:template>
  142.  
  143.     <!-- current node is a table:table or table:sub-table -->
  144.     <xsl:template name="create-table-children">
  145.         <xsl:param name="globalData" />
  146.         <xsl:param name="allVisibleTableRows" />
  147.         <xsl:param name="allTableColumns" />
  148.  
  149.  
  150.         <xsl:for-each select="$allTableColumns/table:table-column">
  151.             <xsl:if test="not(@table:visibility = 'collapse' or @table:visibility = 'filter')">
  152.  
  153.                 <xsl:call-template name="create-column-element">
  154.                     <xsl:with-param name="globalData"           select="$globalData" />
  155.                     <xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
  156.                     <xsl:with-param name="allTableColumns"      select="$allTableColumns" />
  157.                 </xsl:call-template>
  158.             </xsl:if>
  159.         </xsl:for-each>
  160.  
  161.         <xsl:call-template name="create-table-rows">
  162.             <xsl:with-param name="globalData"           select="$globalData" />
  163.             <xsl:with-param name="allVisibleTableRows"  select="$allVisibleTableRows" />
  164.             <xsl:with-param name="allTableColumns"      select="$allTableColumns" />
  165.         </xsl:call-template>
  166.     </xsl:template>
  167.  
  168.     <!-- To be OVERWRITTEN -->
  169.     <xsl:template name="create-column-element" />
  170.  
  171.     <!-- current node is a table:table-column -->
  172.     <xsl:template name="adding-column-styles-entries">
  173.         <xsl:param name="globalData" />
  174.         <xsl:param name="allTableColumns" />
  175.  
  176.         <xsl:choose>
  177.             <!-- if parser reads DTD the default is set to '1' -->
  178.             <xsl:when test="not(@table:number-columns-repeated and @table:number-columns-repeated > 1)">
  179.                 <!-- writes an entry of a column in the columns-variable -->
  180.                 <xsl:copy-of select="." />
  181.             </xsl:when>
  182.             <!-- No higher repetition of cells greater than 99 for the last and second last column.
  183.                  This is a workaround for some sample document (Waehrungsumrechner.sxc),
  184.                  having 230 repeated columns in the second last column to emulate background -->
  185.             <!-- 2DO: Testcase with a table containing table:table-column-group and/or table:table-header-columns -->
  186.             <xsl:when test="(last() or (last() - 1)) and @table:number-columns-repeated > 99">
  187.                 <!-- writes an entry of a column in the columns-variable -->
  188.                 <xsl:call-template name="repeat-adding-table-column">
  189.                     <xsl:with-param name="numberColumnsRepeated"    select="1" />
  190.                 </xsl:call-template>
  191.             </xsl:when>
  192.             <xsl:otherwise>
  193.                 <!-- repeated colums will be written explicit several times in the variable-->
  194.                 <xsl:call-template name="repeat-adding-table-column">
  195.                     <xsl:with-param name="numberColumnsRepeated"    select="@table:number-columns-repeated" />
  196.                 </xsl:call-template>
  197.             </xsl:otherwise>
  198.         </xsl:choose>
  199.      </xsl:template>
  200.  
  201.  
  202.     <!-- WRITES THE REPEATED COLUMN STYLE EXPLICIT AS AN ELEMENT IN THE COLUMNS-VARIABLE -->
  203.     <!-- current node is a table:table-column -->
  204.     <xsl:template name="repeat-adding-table-column">
  205.         <xsl:param name="table:table-column" />
  206.         <xsl:param name="numberColumnsRepeated" />
  207.  
  208.  
  209.         <xsl:choose>
  210.             <xsl:when test="$numberColumnsRepeated > 1">
  211.                 <!-- writes an entry of a column in the columns-variable -->
  212.                 <xsl:copy-of select="." />
  213.                 <!-- repeat calling this method until all elements written out -->
  214.                 <xsl:call-template name="repeat-adding-table-column">
  215.                     <xsl:with-param name="numberColumnsRepeated"    select="$numberColumnsRepeated - 1" />
  216.                 </xsl:call-template>
  217.             </xsl:when>
  218.             <xsl:otherwise>
  219.                 <!-- writes an entry of a column in the columns-variable -->
  220.                 <xsl:copy-of select="." />
  221.             </xsl:otherwise>
  222.         </xsl:choose>
  223.     </xsl:template>
  224.  
  225.  
  226.     <!--debugEnabled-START-->
  227.     <!-- giving out the 'allColumnStyle' variable:
  228.         For each 'table:table-column' of the 'allTableColumns' variable the style-name is given out.
  229.         In case of 'column-hidden-flag' attribute the text 'Column is hidden is given out.-->
  230.     <!-- current node is a table:table or table:sub-table -->
  231.     <xsl:template name="table-debug-allTableColumns">
  232.         <xsl:param name="allTableColumns" />
  233.  
  234.         <!-- debug output as table summary attribut in html -->
  235.         <xsl:attribute name="summary">
  236.             <xsl:call-template name="table-debug-column-out">
  237.                 <xsl:with-param name="allTableColumns" select="$allTableColumns" />
  238.             </xsl:call-template>
  239.         </xsl:attribute>
  240.         <!-- debug output to console -->
  241.         <xsl:message>
  242.             <xsl:call-template name="table-debug-column-out">
  243.                 <xsl:with-param name="allTableColumns" select="$allTableColumns" />
  244.             </xsl:call-template>
  245.         </xsl:message>
  246.     </xsl:template>
  247.  
  248.     <!-- current node is a table:table or table:sub-table -->
  249.     <xsl:template name="table-debug-column-out">
  250.         <xsl:param name="allTableColumns" />
  251.             <xsl:text>
  252.             DebugInformation: For each 'table:table-column' of the 'allTableColumns' variable the style-name is given out.
  253.                               In case of table:visibility attribute unequal 'visible' the 'column is hidden' no text is given out.
  254.             </xsl:text>
  255.                 <xsl:for-each select="$allTableColumns/table:table-column">
  256.                 <xsl:choose>
  257.                 <xsl:when test="@table:visibility = 'collapse' or @table:visibility = 'filter' ">
  258.             <xsl:text>  </xsl:text><xsl:value-of select="@table:style-name" /><xsl:text>column is hidden</xsl:text><xsl:text>
  259.             </xsl:text>
  260.                 </xsl:when>
  261.                 <xsl:otherwise>
  262.             <xsl:text>  </xsl:text><xsl:value-of select="@table:style-name" /><xsl:text> </xsl:text><xsl:value-of select="@table:default-cell-style-name" /><xsl:text>
  263.             </xsl:text>
  264.                 </xsl:otherwise>
  265.                 </xsl:choose>
  266.                            </xsl:for-each>
  267.     </xsl:template>
  268.     <!--debugEnabled-END-->
  269.  
  270. </xsl:stylesheet>
  271.